///////////////////////////////////////////////////////////////////////////////////////////////////////

 float4x4 xView;
float4x4 xProjection;
float4x4 xWorld;
float4 xTopColor;    
float4 xBottomColor; 
 
//------- Texture Samplers --------
Texture xCloudTexture;

sampler TextureSamplerCloud = sampler_state { texture = <xCloudTexture> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;};


 struct SDVertexToPixel
 {    
     float4 Position         : POSITION;
     float2 TextureCoords    : TEXCOORD0;
     float4 ObjectPosition    : TEXCOORD1;
 };
 
 struct SDPixelToFrame
 {
     float4 Color : COLOR0;
 };
 
 SDVertexToPixel SkyDomeVS( float4 inPos : POSITION, float2 inTexCoords: TEXCOORD0)
 {    
     SDVertexToPixel Output = (SDVertexToPixel)0;
     float4x4 preViewProjection = mul (xView, xProjection);
     float4x4 preWorldViewProjection = mul (xWorld, preViewProjection);
     
     Output.Position = mul(inPos, preWorldViewProjection);
     Output.TextureCoords = inTexCoords;
     Output.ObjectPosition = inPos;
     
     return Output;    
 }
 
 SDPixelToFrame SkyDomePS(SDVertexToPixel PSIn)
 {
     SDPixelToFrame Output = (SDPixelToFrame)0;        
 
        
     
     float4 baseColor = lerp(xBottomColor, xTopColor, saturate((PSIn.ObjectPosition.y)));
     float4 cloudValue = tex2D(TextureSamplerCloud, PSIn.TextureCoords).r;
     
     Output.Color = lerp(baseColor,1, cloudValue);        
     //Output.Color *= PSIn.ObjectPosition.y /1.2;
     return Output;
 }
 
 technique SkyDome
 {
     pass Pass0
     {
         VertexShader = compile vs_1_1 SkyDomeVS();
         PixelShader = compile ps_2_0 SkyDomePS();
     }
 }
 
 
 
 
 ////////////////////////////////////////////////////////////////////////////////////////////////
 //DEPTHMAP GENERATION

 struct DMapVertexToPixel
 {
     float4 Position     : POSITION;
     float4 Position2D    : TEXCOORD0;
 };
 
 struct DMapPixelToFrame
 {
     float4 Color : COLOR0;
 };
 
 DMapVertexToPixel DepthMapVertexShader( float4 inPos : POSITION)
 {
     DMapVertexToPixel Output = (DMapVertexToPixel)0;
 
 	 float4x4 preViewProjection = mul (xView, xProjection);
	 float4x4 preWorldViewProjection = mul (xWorld, preViewProjection);
	
     Output.Position = mul(inPos, preWorldViewProjection);
     Output.Position2D = Output.Position;
 
     return Output;
 }
 
 DMapPixelToFrame DepthMapPixelShader(DMapVertexToPixel PSIn)
 {
     DMapPixelToFrame Output = (DMapPixelToFrame)0;   
              
	 Output.Color = 0;  
	
     return Output;
 }
 
 technique DepthMap
 {
     pass Pass0
     {
         VertexShader = compile vs_2_0 DepthMapVertexShader();
         PixelShader = compile ps_2_0 DepthMapPixelShader();
     }
 }